#include<iostream>
#define maxn 2010
using namespace std;
int f[maxn][maxn];
int main(){
    string s1,s2;
    cin>>s1>>s2;
    
    int cd1=s1.length();
    int cd2=s2.length();
    for(int i=1;i<=cd1;i++){
        f[i][0]=i;
    }
     for(int i=1;i<=cd2;i++){
        f[0][i]=i;
    }
    for(int i=1;i<=cd1;i++){
        for(int j=1;j<=cd2;j++){
            f[i][j]=min(min(f[i][j-1]+1,f[i-1][j]+1),f[i-1][j-1]+(s1[i-1]!=s2[j-1]));
        }
    }
    cout<<f[cd1][cd2];
    return 0;
}